Skip to content

Conversation

@amcclain
Copy link
Member

  • Extend use of FilterBindTarget and FilterValueSource interfaces to GridFilterModel. Its bind config is now typed to be the union of the two - previous Store | View type continues to satisfy but now open to more extensible usage.
  • Improve typing coverage on GridModel private methods, add types and type guards where helpful to better cover this code. Should be no functional changes.

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

if (selModel === undefined) {
selModel = XH.isMobileApp ? 'disabled' : 'single';
} else if (selModel === null) {
selModel = 'disabled';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found being explicit here a bit more clear than the previous use of withDefault (the undefined case) and then a null check down below.

@amcclain amcclain requested a review from lbwexler January 15, 2026 22:41
@amcclain
Copy link
Member Author

@lbwexler added you as a reviewer to keep you in the loop and of course your feedback / review always welcome, but pls don't feel any pressure to take time out of your trip - this is I hope a largely mechanical expansion of type coverage.

fieldSpecDefaults?: Omit<GridFilterFieldSpecConfig, 'field'>;
}

export type GridFilterBindTarget = FilterBindTarget & FilterValueSource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suggesting there is anything wrong with this, but should we be favoring interface extension over the intersection type here?

https://github.com/microsoft/TypeScript/wiki/Performance#preferring-interfaces-over-intersections
https://www.typescriptlang.org/docs/handbook/2/objects.html#interface-extension-vs-intersection

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you for the links - very happy to learn something + follow best practices.

Pushed this change. Do you know - should we be explicit about Store/View extending GridFilterBindTarget in addition to the two sub-interfaces?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm -- we could have them explicitly implement GridFilterBindTarget That seems reasonable to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushing that to develop now.

export type ColumnOrGroupSpec = ColumnSpec | ColumnGroupSpec;

export function isColumnSpec(spec: ColumnOrGroupSpec): spec is ColumnSpec {
return !(spec as ColumnGroupSpec).children;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being nit-picky, but the cast feels a little funny here since we actually don't know that spec is a ColumnGroupSpec. Would you be opposed to return !('children' in spec)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree it's strange to see the very assertion you are testing for.

The one thing I don't especially like about the quoted string 'children' is that there's nothing in type-world that then helps us if we were to ever change that name - i.e. nothing that's checking that the thing we're using the check is in fact part of the type we are checking for.

But by the same token, nothing would help us in either case if we (for some reason) added a children property to ColumnSpec. I suppose it's just generally what you need to accept when writing these guards - either you decide to go all out and exhaustively test the shape or you take responsibility for implementing (and keeping track of) whatever distinctions you have decided need to be made.

Happy to make this change. Also considered (spec as any) but doesn't improve on 'children' in in any way and checking for in ultimately more correct in that we're not really looking for a runtime truthiness check here, either.

@amcclain amcclain merged commit baa07f9 into develop Jan 16, 2026
1 check passed
@amcclain amcclain deleted the gridModelTypeAdds branch January 16, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants